package com.jaux.hotel.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jaux.hotel.common.Result;
import com.jaux.hotel.dto.ClassesDetailDto;
import com.jaux.hotel.mapper.ClassesMapper;
import com.jaux.hotel.pojo.Classes;
import com.jaux.hotel.service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author JAUX
 */
@Service
public class ClassesServiceImpl extends ServiceImpl<ClassesMapper, Classes> implements ClassesService {
    @Autowired
    private ClassesMapper classesMapper;

    /**
     * 查询班级学生
     * @param classesId 班级id
     * @return 返回班级信息
     */
    @Override
    public Result<ClassesDetailDto> selectClassList(String classesId) {
        ClassesDetailDto classesDetailDto = null;
        try {
            classesDetailDto = classesMapper.selectClassList(classesId);
        } catch (Exception e){
            return Result.error("查询失败",505);
        }
        return Result.success(classesDetailDto,"查询成功");
    }

    @Override
    public String addClass(Classes classes) {
        boolean insert = this.save(classes);
        if (insert){
            return "添加成功";
        }else {
            return "添加失败";
        }
    }


}
